package com.zsp.coupon.constant;


import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

/** 产品线枚举*/
@Getter
//@AllArgsConstructor
public enum ProdcutLine {
    DAMAO("大猫",1),
    DABAO("大宝",2);

    ProdcutLine(String description, Integer code) {
        this.description = description;
        this.code = code;
    }

    public String getDescription() {
        return description;
    }

    public Integer getCode() {
        return code;
    }

    private String description;
    private  Integer  code;

    public static ProdcutLine of(Integer code){
        Objects.requireNonNull(code);
        return Stream.of(values()).filter(bean ->bean.code.equals(code))
                .findAny()
                .orElseThrow(()-> new IllegalArgumentException(code+"not exists"));
    }


}
